# nuraft.cmake
# 本文件包含着从外部导入 NuRaft 所需要的信息

INCLUDE(ExternalProject)

set(NURAFT_ROOT ${PROJECT_SOURCE_DIR}/extern_module_download/nuraft)
set(NURAFT_GIT_URL      https://atomgit.com/dangaldb/NuRaft-Mirror.git)  # 指定git仓库地址
set(NURAFT_CONFIGURE    cd ${NURAFT_ROOT}/src/extern_nuraft && ./prepare.sh)
set(NURAFT_MAKE         cd ${NURAFT_ROOT}/src/extern_nuraft && cmake . -DCMAKE_INSTALL_PREFIX=${NURAFT_ROOT}/output)
set(NURAFT_INSTALL      cd ${NURAFT_ROOT}/src/extern_nuraft && make install) 

ExternalProject_Add(extern_nuraft
        PREFIX            ${NURAFT_ROOT}
        GIT_REPOSITORY    ${NURAFT_GIT_URL}
        CONFIGURE_COMMAND ${NURAFT_CONFIGURE}
        BUILD_COMMAND     ${NURAFT_MAKE}
        INSTALL_COMMAND   ${NURAFT_INSTALL}
        CMAKE_ARGS
        -DCMAKE_INSTALL_PREFIX=${NURAFT_ROOT}/output
        -DBUILD_SHARED_LIBS=OFF
        -DBUILD_STATIC_LIBS=ON
)

INCLUDE_DIRECTORIES(${NURAFT_ROOT}/output/include)
LINK_DIRECTORIES(${NURAFT_ROOT}/output/lib)